package basicelement;

import java.util.Date;

public class MarketPosition {
	
	public static int SOLD = -1;
	public static int BOUGHT = 1;
	public static int NEUTRAL = 0;

	private boolean block = true;
	
	private String lowStockOptionName = "";
	private String highStockOptionName = "";
	
	private Date instantTime;
	private double money;
	private double blocked;
	private long qttLowStockOption;
	private long qttHighStockOption;
	private double lowStockPriceOrdered;
	private double highStockPriceOrdered;
	
	public MarketPosition(String instantTime, String lowStockOptionName, 
			String highStockOptionName,	double money, double blocked,
			long qttLowStockOption, long qttHighStockOption,
			double lowStockPriceOrdered, double highStockPriceOrdered) {
		super();
		try {
			this.instantTime = TendencyIndicator.formatDate(instantTime);
		} catch (Exception e) {			 
			e.printStackTrace();  
		}  
		this.lowStockOptionName = lowStockOptionName;
		this.highStockOptionName = highStockOptionName;
		this.money = money;
		this.blocked = blocked;
		this.qttLowStockOption = qttLowStockOption;
		this.qttHighStockOption = qttHighStockOption;
		this.lowStockPriceOrdered = lowStockPriceOrdered;
		this.highStockPriceOrdered = highStockPriceOrdered;
	}
	
	public String getLowStockOptionName() {
		return lowStockOptionName;
	}
	public void setLowStockOptionName(String lowStockOptionName) {
		this.lowStockOptionName = lowStockOptionName;
	}
	public String getHighStockOptionName() {
		return highStockOptionName;
	}
	public void setHighStockOptionName(String highStockOptionName) {
		this.highStockOptionName = highStockOptionName;
	}
	public Date getInstantTime() {
		return instantTime;
	}
	public void setInstantTime(Date instantTime) {
		this.instantTime = instantTime;
	}
	public double getMoney() {
		return money;
	}
	public void setMoney(double money) {
		this.money = money;
	}
	public double getBlocked() {
		return blocked;
	}
	public void setBlocked(double blocked) {
		this.blocked = blocked;
	}
	public long getQttLowStockOption() {
		return qttLowStockOption;
	}
	public void setQttLowStockOption(long qttLowStockOption) {
		this.qttLowStockOption = qttLowStockOption;
	}
	public long getQttHighStockOption() {
		return qttHighStockOption;
	}
	public void setQttHighStockOption(long qttHighStockOption) {
		this.qttHighStockOption = qttHighStockOption;
	}
	public double getLowStockPriceOrdered() {
		return lowStockPriceOrdered;
	}
	public void setLowStockPriceOrdered(double lowStockPriceOrdered) {
		this.lowStockPriceOrdered = lowStockPriceOrdered;
	}
	public double getHighStockPriceOrdered() {
		return highStockPriceOrdered;
	}
	public void setHighStockPriceOrdered(double highStockPriceOrdered) {
		this.highStockPriceOrdered = highStockPriceOrdered;
	}

	public int getPosition(){
		if (qttHighStockOption>0 && qttLowStockOption==0)
			return this.BOUGHT;
		
		if (qttLowStockOption<0)
			return this.SOLD;
		
		if (qttHighStockOption==0 && qttLowStockOption==0)
			return this.NEUTRAL;
		
		return this.NEUTRAL;
	}
	
	
	@Override
	public String toString() {
		return this.instantTime + ";" + 
				lowStockOptionName  + ";" + qttLowStockOption + ";" + lowStockPriceOrdered + ";" + 
				highStockOptionName + ";" + qttHighStockOption + ";" + highStockPriceOrdered + ";" + 
				money + ";" + blocked;
	}
	
	
	


}
